314499cee078e42353b3373901368152d7c4fa4e,src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java,AllocationService,electPrimariesAndUnassignDanglingReplicas,#RoutingAllocation#,246
Before Change
// go over and remove dangling replicas that are initializing, but we couldn't elect primary ones...
List<ShardRouting> shardsToFail = null;
for (MutableShardRouting shardEntry : routingNodes.unassigned()) {
if (shardEntry.primary() && !shardEntry.assignedToNode()) {
for (RoutingNode routingNode : routingNodes) {
for (MutableShardRouting shardEntry2 : routingNode) {
if (shardEntry.shardId().equals(shardEntry2.shardId()) && !shardEntry2.active()) {
changed = true;
if (shardsToFail == null) {
shardsToFail = new ArrayList<ShardRouting>();
After Change
List<ShardRouting> shardsToFail = null;
if (routingNodes.hasUnassignedPrimaries()) {
for (MutableShardRouting shardEntry : routingNodes.unassigned()) {
if (shardEntry.primary()) {
for(MutableShardRouting routing : routingNodes.assignedShards(shardEntry)) {
if (!routing.primary()) {
changed = true;